home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / INC.PAK / IOSTREAM.H < prev    next >
C/C++ Source or Header  |  1997-05-06  |  36KB  |  872 lines

  1. /*  iostream.h -- basic stream I/O declarations
  2.  
  3.     There are some inline functions here which generate a LOT of code
  4.     (as much as 300 bytes), but are available inline because AT&T did
  5.     it that way.  We have also made them true functions in the library
  6.     and conditionally deleted the inline code from this header.
  7.  
  8.     If you really want these big functions to be inline, #define the
  9.     macro name _BIG_INLINE_ before including this header.
  10.  
  11.     Programs will compile and link correctly even if some modules are
  12.     compiled with _BIG_INLINE_ and some are not.
  13. */
  14.  
  15. /*
  16.  *      C/C++ Run Time Library - Version 8.0
  17.  *
  18.  *      Copyright (c) 1990, 1997 by Borland International
  19.  *      All Rights Reserved.
  20.  *
  21.  */
  22. /* $Revision:   8.7  $ */
  23.  
  24. #ifndef __cplusplus
  25. #error Must use C++ for the type iostream.
  26. #endif
  27.  
  28. #ifndef __IOSTREAM_H
  29. #define __IOSTREAM_H
  30.  
  31. #if !defined(___DEFS_H)
  32. #include <_defs.h>
  33. #endif
  34.  
  35. #if !defined(__STRING_H)
  36. #include <string.h>    // to get strnicmp, memcpy and NULL
  37. #endif
  38.  
  39.  
  40. #if !defined(RC_INVOKED)
  41.  
  42. #pragma pack(push, 1)
  43.  
  44. #if defined(__BCOPT__)
  45. #if !defined(_RTL_ALLOW_po) && !defined(__FLAT__)
  46. #pragma option -po-     // disable Object data calling convention
  47. #endif
  48. #endif
  49.  
  50. #if !defined(__TINY__)
  51. #pragma option -RT
  52. #endif
  53.  
  54. #pragma option -Vo-     // set standard C++ options
  55.  
  56. #if defined(__STDC__)
  57. #pragma warn -nak
  58. #endif
  59.  
  60. #endif  /* !RC_INVOKED */
  61.  
  62.  
  63. // Definition of EOF must match the one in <stdio.h>
  64. #define EOF (-1)
  65.  
  66. // extract a char from int i, ensuring that zapeof(EOF) != EOF
  67. #define zapeof(i) ((unsigned char)(i))
  68.  
  69. typedef long streampos;
  70. typedef long streamoff;
  71.  
  72. _CLASSDEF(ios)
  73. _CLASSDEF(streambuf)
  74. _CLASSDEF(istream)
  75. _CLASSDEF(ostream)
  76. _CLASSDEF(iostream)
  77. _CLASSDEF(istream_withassign)
  78. _CLASSDEF(ostream_withassign)
  79. _CLASSDEF(iostream_withassign)
  80.  
  81. class _EXPCLASS ios {
  82. public:
  83.     // stream status bits
  84.     enum io_state   {
  85.         goodbit  = 0x00,    // no bit set: all is ok
  86.         eofbit   = 0x01,    // at end of file
  87.         failbit  = 0x02,    // last I/O operation failed
  88.         badbit   = 0x04,    // invalid operation attempted
  89.         hardfail = 0x80     // unrecoverable error
  90.         };
  91.  
  92.     // stream operation mode
  93.     enum open_mode  {
  94.         in   = 0x01,        // open for reading
  95.         out  = 0x02,        // open for writing
  96.         ate  = 0x04,        // seek to eof upon original open
  97.         app  = 0x08,        // append mode: all additions at eof
  98.         trunc    = 0x10,    // truncate file if already exists
  99.         nocreate = 0x20,    // open fails if file doesn't exist
  100.         noreplace= 0x40,    // open fails if file already exists
  101.         binary   = 0x80     // binary (not text) file
  102.         };
  103.  
  104.     // stream seek direction
  105.     enum seek_dir { beg=0, cur=1, end=2 };
  106.  
  107.     // formatting flags
  108.     enum    {
  109.         skipws    = 0x0001, // skip whitespace on input
  110.         left      = 0x0002, // left-adjust output
  111.         right     = 0x0004, // right-adjust output
  112.         internal  = 0x0008, // padding after sign or base indicator
  113.         dec       = 0x0010, // decimal conversion
  114.         oct       = 0x0020, // octal conversion
  115.         hex       = 0x0040, // hexadecimal conversion
  116.         showbase  = 0x0080, // use base indicator on output
  117.         showpoint = 0x0100, // force decimal point (floating output)
  118.         uppercase = 0x0200, // upper-case hex output
  119.         showpos   = 0x0400, // add '+' to positive integers
  120.         scientific= 0x0800, // use 1.2345E2 floating notation
  121.         fixed     = 0x1000, // use 123.45 floating notation
  122.         unitbuf   = 0x2000, // flush all streams after insertion
  123.         stdio     = 0x4000, // flush stdout, stderr after insertion
  124.         boolalpha = 0x8000  // insert/extract bools as text or numeric
  125.         };
  126.  
  127.     // constants for second parameter of seft()
  128. static  const long basefield;       // dec | oct | hex
  129. static  const long adjustfield;     // left | right | internal
  130. static  const long floatfield;      // scientific | fixed
  131.  
  132.     // constructor, destructor
  133.             _RTLENTRY ios(streambuf _FAR *);
  134. virtual     _RTLENTRY ~ios();
  135.  
  136.     // for reading/setting/clearing format flags
  137.     long    _RTLENTRY flags();
  138.     long    _RTLENTRY flags(long);
  139.     long    _RTLENTRY setf(long _setbits, long _field);
  140.     long    _RTLENTRY setf(long);
  141.     long    _RTLENTRY unsetf(long);
  142.  
  143.     // reading/setting field width
  144.     int     _RTLENTRY width();
  145.     int     _RTLENTRY width(int);
  146.  
  147.     // reading/setting padding character
  148.     char    _RTLENTRY fill();
  149.     char    _RTLENTRY fill(char);
  150.  
  151.     // reading/setting digits of floating precision
  152.     int     _RTLENTRY precision(int);
  153.     int     _RTLENTRY precision();
  154.  
  155.     // reading/setting ostream tied to this stream
  156.     ostream _FAR * _RTLENTRY tie(ostream _FAR *);
  157.     ostream _FAR * _RTLENTRY tie();
  158.  
  159.     // find out about current stream state
  160.     int     _RTLENTRY rdstate();       // return the stream state
  161.     int     _RTLENTRY eof();           // non-zero on end of file
  162.     int     _RTLENTRY fail();          // non-zero if an operation failed
  163.     int     _RTLENTRY bad();           // non-zero if error occurred
  164.     int     _RTLENTRY good();          // non-zero if no state bits set
  165.     void    _RTLENTRY clear(int = 0);  // set the stream state
  166.             _RTLENTRY operator void _FAR * (); // zero if state failed
  167.     int     _RTLENTRY operator! ();    // non-zero if state failed
  168.  
  169.     streambuf _FAR * _RTLENTRY rdbuf();        // get the assigned streambuf
  170.  
  171.     // for declaring additional flag bits and user words
  172. static long _RTLENTRY bitalloc();  // acquire a new flag bit, value returned
  173. static int  _RTLENTRY xalloc();    // acquire a new user word, index returned
  174.     long    _FAR & _RTLENTRY iword(int);  // return the nth user word as an int
  175.     void    _FAR * _FAR & _RTLENTRY pword(int);  // return the nth user word as a pointer
  176.  
  177. static void _RTLENTRY sync_with_stdio();
  178.  
  179.     // obsolete, for streams 1.2 compatibility
  180.     int     _RTLENTRY skip(int);
  181.  
  182.     int     delbuf() {return x_delbuf;}
  183.     int     delbuf(int _new) {int _x=x_delbuf;x_delbuf=_new;return _x;}
  184. protected:
  185.     // additional state flags for ispecial and ospecial
  186.     enum { skipping = 0x100, tied = 0x200 };
  187.  
  188.     streambuf _FAR * bp;    // the associated streambuf
  189.     ostream _FAR * x_tie;   // the tied ostream, if any
  190.     int     state;          // status bits
  191.     int     ispecial;       // istream status bits  ***
  192.     int     ospecial;       // ostream status bits  ***
  193.     long    x_flags;        // formatting flag bits
  194.     int     x_precision;    // floating-point precision on output
  195.     int     x_width;        // field width on output
  196.     int     x_fill;         // padding character on output
  197.     int     isfx_special;   // unused       ***
  198.     int     osfx_special;   // unused       ***
  199.     int     x_delbuf;       // unused       ***
  200.     int     assign_private; // unused       ***
  201. /*
  202.  * The data members marked with *** above are not documented in the AT&T
  203.  * release of streams, so we cannot guarantee compatibility with any
  204.  * other streams release in the use or values of these data members.
  205.  * If you can document any expected behavior of these data members, we
  206.  * will try to adjust our implementation accordingly.
  207.  */
  208.  
  209.             _RTLENTRY ios();       // null constructor, does not initialize
  210.  
  211.     void    _RTLENTRY init(streambuf _FAR *);  // the actual initialization
  212.  
  213.     void    _RTLENTRY setstate(int);       // set all status bits
  214.  
  215. static  void _RTLENTRY (*stdioflush)();
  216.  
  217. private:
  218.     // for extra flag bits and user words
  219. static  long    nextbit;
  220. static  int usercount;
  221.     union ios_user_union _FAR *userwords;
  222.     int     nwords;
  223.     void    _RTLENTRY usersize(int);
  224.  
  225.     // these declarations prevent automatic copying of an ios
  226.             _RTLENTRY ios(ios _FAR &);           // declared but not defined
  227.     void    _RTLENTRY operator= (ios _FAR &);    // declared but not defined
  228.  
  229. };
  230. inline streambuf _FAR * _RTLENTRY ios::rdbuf() { return bp; }
  231. inline ostream _FAR * _RTLENTRY ios::tie() { return x_tie; }
  232. inline char     _RTLENTRY ios::fill() { return (char)x_fill; }
  233. inline int      _RTLENTRY ios::precision() { return x_precision; }
  234. inline int      _RTLENTRY ios::rdstate() { return state; }
  235. inline int      _RTLENTRY ios::eof() { return state & eofbit; }
  236. inline int      _RTLENTRY ios::fail()
  237.                         { return state & (failbit | badbit | hardfail); }
  238. inline int      _RTLENTRY ios::bad() { return state & (badbit | hardfail); }
  239. inline int      _RTLENTRY ios::good() { return state == 0; }
  240. inline long     _RTLENTRY ios::flags() { return x_flags; }
  241. inline int      _RTLENTRY ios::width() { return x_width; }
  242. inline int      _RTLENTRY ios::width(int _w)
  243.                         { int _i = x_width; x_width = _w; return _i; }
  244. inline char     _RTLENTRY ios::fill(char _c)
  245.                         { char _x = (char)x_fill; x_fill = _c; return _x; }
  246. inline int      _RTLENTRY ios::precision(int _p)
  247.                         { int _x = x_precision; x_precision = _p; return _x; }
  248. inline          _RTLENTRY ios::operator void _FAR *()
  249.                         { return fail() ? 0 : this; }
  250. inline int      _RTLENTRY ios::operator! () { return fail(); }
  251.  
  252.  
  253. class _EXPCLASS streambuf {
  254. public:
  255.     // constructors and destructors
  256.         _RTLENTRY streambuf();                 // make empty streambuf
  257.         _RTLENTRY streambuf(char _FAR *, int); // make streambuf with
  258.                                             // given char array
  259. virtual _RTLENTRY ~streambuf();
  260.  
  261.     // use the provided char array for the buffer if possible
  262. virtual streambuf _FAR * _RTLENTRY setbuf(char _FAR *, int);
  263.  
  264.     // obsolete, for streams 1.2 compatibility
  265.     streambuf _FAR *  _RTLENTRY setbuf(char _FAR *, int, int);
  266.  
  267.     // getting (extracting) characters
  268.     int     _RTLENTRY sgetc();         // peek at next char
  269.     int     _RTLENTRY snextc();        // advance to and return next char
  270.     int     _RTLENTRY sbumpc();        // return current char and advance
  271.     void    _RTLENTRY stossc();        // advance to next character
  272.     int     _RTLENTRY sgetn(char _FAR *, int);     // get next n chars
  273. virtual int _RTLENTRY do_sgetn(char _FAR *, int);  // implementation of sgetn
  274. virtual int _RTLENTRY underflow();     // fill empty buffer
  275.     int     _RTLENTRY sputbackc(char); // return char to input
  276. virtual int _RTLENTRY pbackfail(int);  // implementation of sputbackc
  277.     int     _RTLENTRY in_avail();      // number of avail chars in buffer
  278.  
  279.     // putting (inserting) characters
  280.     int     _RTLENTRY sputc(int);          // put one char
  281.     int     _RTLENTRY sputn(const char _FAR *, int); // put n chars from string
  282. virtual int _RTLENTRY do_sputn(const char _FAR * s, int n); // implementation of sputn
  283. virtual int _RTLENTRY overflow(int = EOF); // flush buffer and make more room
  284.     int     _RTLENTRY out_waiting();       // number of unflushed chars
  285.  
  286.     // moving around in stream
  287. virtual streampos _RTLENTRY seekoff(streamoff, ios::seek_dir,
  288.                                  int = (ios::in | ios::out));
  289. virtual streampos _RTLENTRY seekpos(streampos, int = (ios::in | ios::out));
  290. virtual int _RTLENTRY sync();
  291.  
  292. #if defined(__FLAT__)
  293.     // locking and unlocking file handle associated with stream
  294. virtual void _RTLENTRY lock();
  295. virtual void _RTLENTRY unlock();
  296. #endif
  297.  
  298.     void    _RTLENTRY dbp();       // for debugging streambuf implementations
  299.  
  300. protected:
  301.     char _FAR * _RTLENTRY base();  // return start of buffer area
  302.     char _FAR * _RTLENTRY ebuf();  // return end+1 of buffer area
  303.     int     _RTLENTRY blen();      // return length of buffer area
  304.     char _FAR * _RTLENTRY pbase(); // return start of put area
  305.     char _FAR * _RTLENTRY pptr();  // return next location in put area
  306.     char _FAR * _RTLENTRY epptr(); // return end+1 of put area
  307.     char _FAR * _RTLENTRY eback(); // return base of putback section of get area
  308.     char _FAR * _RTLENTRY gptr();  // return next location in get area
  309.     char _FAR * _RTLENTRY egptr(); // return end+1 of get area
  310.     void    _RTLENTRY setp(char _FAR *, char _FAR *); // initialize the put pointers
  311.     void    _RTLENTRY setg(char _FAR *, char _FAR *, char _FAR *); // initialize the get pointers
  312.     void    _RTLENTRY pbump(int);  // advance the put pointer
  313.     void    _RTLENTRY gbump(int);  // advance the get pointer
  314.     void    _RTLENTRY setb(char _FAR *, char _FAR *, int = 0 );    // set the buffer area
  315.     void    _RTLENTRY unbuffered(int);// set the buffering state
  316.     int     _RTLENTRY unbuffered();    // non-zero if not buffered
  317.     int     _RTLENTRY allocate();  // set up a buffer area
  318. virtual int _RTLENTRY doallocate();    // implementation of allocate
  319.  
  320. private:
  321.     short   alloc_;     // non-zero if buffer should be deleted
  322.     short   unbuf_;     // non-zero if unbuffered
  323.     char _FAR * base_;  // start of buffer area
  324.     char _FAR * ebuf_;  // end+1 of buffer area
  325.     char _FAR * pbase_; // start of put area
  326.     char _FAR * pptr_;  // next put location
  327.     char _FAR * epptr_; // end+1 of put area
  328.     char _FAR * eback_; // base of putback section of get area
  329.     char _FAR * gptr_;  // next get location
  330.     char _FAR * egptr_; // end+1 of get area
  331.  
  332.     int     _RTLENTRY do_snextc(); // implementation of snextc
  333.  
  334.     // these declarations prevent copying of a streambuf
  335.             _RTLENTRY streambuf(streambuf _FAR &);   // declared but not defined
  336.     void    _RTLENTRY operator= (streambuf _FAR &);  // declared but not defined
  337. };
  338. inline char _FAR * _RTLENTRY streambuf::base()  { return base_; }
  339. inline char _FAR * _RTLENTRY streambuf::pbase() { return pbase_; }
  340. inline char _FAR * _RTLENTRY streambuf::pptr()  { return pptr_; }
  341. inline char _FAR * _RTLENTRY streambuf::epptr() { return epptr_; }
  342. inline char _FAR * _RTLENTRY streambuf::gptr()  { return gptr_; }
  343. inline char _FAR * _RTLENTRY streambuf::egptr() { return egptr_; }
  344. inline char _FAR * _RTLENTRY streambuf::eback() { return eback_; }
  345. inline char _FAR * _RTLENTRY streambuf::ebuf()  { return ebuf_; }
  346. inline int   _RTLENTRY streambuf::unbuffered()  { return unbuf_; }
  347. inline int   _RTLENTRY streambuf::blen() { return (int)(ebuf_ - base_);}
  348. inline void _RTLENTRY streambuf::pbump(int _n) { pptr_ += _n; }
  349. inline void _RTLENTRY streambuf::gbump(int _n) { gptr_ += _n; }
  350. inline void _RTLENTRY streambuf::unbuffered(int _unb) { unbuf_ = (short)(_unb != 0); }
  351. inline int  _RTLENTRY streambuf::in_avail()
  352.                 { return (egptr_ > gptr_) ? (int)(egptr_ - gptr_) : 0; }
  353. inline int  _RTLENTRY streambuf::out_waiting()
  354.                 { return pptr_ ? (int)(pptr_ - pbase_) : 0; }
  355. inline int  _RTLENTRY streambuf::allocate() {
  356.                 return (base_ || unbuf_) ? 0 : doallocate();
  357.                 }
  358. inline int  _RTLENTRY streambuf::sgetc() {
  359.                 return (gptr_ >= egptr_) ? underflow() :
  360.                    (unsigned char)(*gptr_);
  361.                 }
  362. inline int  _RTLENTRY streambuf::snextc() {
  363.                 return (! gptr_ || (++gptr_ >= egptr_)) ?
  364.                     do_snextc() :
  365.                     (unsigned char)(*gptr_);
  366.                 }
  367. inline int  _RTLENTRY streambuf::sbumpc() {
  368.                 return (gptr_ >= egptr_ && underflow() == EOF) ?
  369.                     EOF :
  370.                     (unsigned char)(*gptr_++);
  371.                 }
  372. inline void _RTLENTRY streambuf::stossc() {
  373.                 if( gptr_ >= egptr_ ) underflow();
  374.                 else ++gptr_;
  375.                 }
  376. inline int  _RTLENTRY streambuf::sputbackc(char _c) {
  377.                 return (gptr_ > eback_) ?
  378.                     (unsigned char)(*--gptr_ = _c) :
  379.                     pbackfail(_c);
  380.                 }
  381. inline int  _RTLENTRY streambuf::sputc(int _c) {
  382.                 return (pptr_ >= epptr_) ?
  383.                     overflow((unsigned char)_c) :
  384.                     (unsigned char)(*pptr_++ = (char)_c);
  385.                 }
  386. #ifdef _BIG_INLINE_
  387. inline int  _RTLENTRY streambuf::sputn(const char _FAR * _s, int _n) {
  388.                 if( _n <= (epptr_ - pptr_) ) {
  389.                     memcpy(pptr_, _s, _n);
  390.                     pbump(_n);
  391.                     return _n;
  392.                 }
  393.                 return do_sputn(_s, _n);
  394.                 }
  395. inline int  _RTLENTRY streambuf::sgetn(char _FAR * _s, int _n) {
  396.                 if( _n <= (egptr_ - gptr_) ) {
  397.                     memcpy(_s, gptr_, _n);
  398.                     gbump(_n);
  399.                     return _n;
  400.                 }
  401.                 return do_sgetn(_s, _n);
  402.                 }
  403. #endif
  404.  
  405. #if defined(__FLAT__)
  406. inline void _RTLENTRY streambuf::lock() {}
  407. inline void _RTLENTRY streambuf::unlock() {}
  408. #endif
  409.  
  410. class _EXPCLASS istream : virtual public ios {
  411. public:
  412.         // constructor and destructor
  413.         _RTLENTRY istream(streambuf _FAR *);
  414. virtual _RTLENTRY ~istream();
  415.  
  416.         // Obsolete constructors, for streams 1.2 compatibility
  417.         // obsolete: set skip via format, tie via tie() function
  418.         _RTLENTRY istream(streambuf _FAR *, int _sk, ostream _FAR * _t=0);
  419.         // obsolete: use strstream
  420.         _RTLENTRY istream(int _sz, char _FAR *, int _sk=1);
  421.         // obsolete: use fstream
  422.         _RTLENTRY istream(int _fd, int _sk=1, ostream _FAR * _t=0);
  423.  
  424.     int _RTLENTRY ipfx(int = 0);       // input prefix function
  425.     int _RTLENTRY ipfx0();     // same as ipfx(0)
  426.     int _RTLENTRY ipfx1();     // same as ipfx(1)
  427.     void _RTLENTRY isfx()      { } // unused input suffix function
  428.  
  429.     // set/read the get pointer's position
  430.     istream _FAR & _RTLENTRY seekg(streampos);
  431.     istream _FAR & _RTLENTRY seekg(streamoff, ios::seek_dir);
  432.     streampos _RTLENTRY tellg();
  433.  
  434.     int _RTLENTRY sync();
  435.  
  436.     /*
  437.      * Unformatted extraction operations
  438.      */
  439.     // extract characters into an array
  440.     istream _FAR & _RTLENTRY get(         char _FAR *, int, char = '\n');
  441.     istream _FAR & _RTLENTRY get(  signed char _FAR *, int, char = '\n');
  442.     istream _FAR & _RTLENTRY get(unsigned char _FAR *, int, char = '\n');
  443.     istream _FAR & _RTLENTRY read(         char _FAR *, int);
  444.     istream _FAR & _RTLENTRY read(  signed char _FAR *, int);
  445.     istream _FAR & _RTLENTRY read(unsigned char _FAR *, int);
  446.  
  447.     // extract characters into an array up to termination char
  448.     istream _FAR & _RTLENTRY getline(         char _FAR *, int, char = '\n');
  449.     istream _FAR & _RTLENTRY getline(  signed char _FAR *, int, char = '\n');
  450.     istream _FAR & _RTLENTRY getline(unsigned char _FAR *, int, char = '\n');
  451.  
  452.     // extract characters into a streambuf up to termination char
  453.     istream _FAR & _RTLENTRY get(streambuf _FAR &, char = '\n');
  454.  
  455.     // extract a single character
  456.     istream _FAR & _RTLENTRY get(         char _FAR &);
  457.     istream _FAR & _RTLENTRY get(  signed char _FAR &);
  458.     istream _FAR & _RTLENTRY get(unsigned char _FAR &);
  459.     int            _RTLENTRY get();
  460.  
  461.     int      _RTLENTRY peek();     // return next char without extraction
  462.     int      _RTLENTRY gcount();   // number of unformatted chars last extracted
  463.     istream _FAR & _RTLENTRY putback(char);  // push back char into input
  464.  
  465.     // extract and discard chars but stop at delim
  466.     istream _FAR & _RTLENTRY ignore(int = 1, int = EOF);
  467.  
  468.     /*
  469.      * Formatted extraction operations
  470.      */
  471.     istream _FAR & _RTLENTRY operator>> (bool _FAR &);
  472.     istream _FAR & _RTLENTRY operator>> (istream _FAR & (_RTLENTRY *_f)(istream _FAR &));
  473.     istream _FAR & _RTLENTRY operator>> (ios _FAR & (_RTLENTRY *_f)(ios _FAR &) );
  474.     istream _FAR & _RTLENTRY operator>> (         char _FAR *);
  475.     istream _FAR & _RTLENTRY operator>> (  signed char _FAR *);
  476.     istream _FAR & _RTLENTRY operator>> (unsigned char _FAR *);
  477.     istream _FAR & _RTLENTRY operator>> (         char _FAR &);
  478.     istream _FAR & _RTLENTRY operator>> (  signed char _FAR &);
  479.     istream _FAR & _RTLENTRY operator>> (unsigned char _FAR &);
  480.     istream _FAR & _RTLENTRY operator>> (short _FAR &);
  481.     istream _FAR & _RTLENTRY operator>> (int _FAR &);
  482.     istream _FAR & _RTLENTRY operator>> (long _FAR &);
  483. #if defined(__FLAT__) && !defined(__STDC__) && (__BORLANDC__  >= 0x0520) && defined (_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS >= 64)
  484.     istream _FAR & _RTLENTRY operator>> (__int64 _FAR &);
  485.     istream _FAR & _RTLENTRY operator>> (unsigned __int64 _FAR &);
  486. #endif
  487.     istream _FAR & _RTLENTRY operator>> (unsigned short _FAR &);
  488.     istream _FAR & _RTLENTRY operator>> (unsigned int _FAR &);
  489.     istream _FAR & _RTLENTRY operator>> (unsigned long _FAR &);
  490.     istream _FAR & _RTLENTRY operator>> (float _FAR &);
  491.     istream _FAR & _RTLENTRY operator>> (double _FAR &);
  492.     istream _FAR & _RTLENTRY operator>> (long double _FAR &);
  493.  
  494.     // extract from this istream, insert into streambuf
  495.     istream _FAR & _RTLENTRY operator>> (streambuf _FAR *);
  496.  
  497. protected:
  498.             _RTLENTRY istream();
  499.     void    _RTLENTRY eatwhite();      // extract consecutive whitespace
  500.  
  501. private:
  502.     int gcount_;    // chars extracted by last unformatted operation
  503.     signed char _RTLENTRY do_get();    // implementation of get
  504. };
  505. inline int  _RTLENTRY istream::gcount() { return gcount_; }
  506. inline int  _RTLENTRY istream::ipfx0()  { return ipfx(0); }
  507. inline int  _RTLENTRY istream::ipfx1()  { return ipfx(1); }
  508. #ifdef _BIG_INLINE_
  509. inline istream _FAR & _RTLENTRY istream::operator>> (char _FAR & _c) {
  510.                 if( ipfx0() )
  511.                     _c = bp->in_avail() ? bp->sbumpc() : do_get();
  512.                 return *this;
  513.                 }
  514. inline istream _FAR & _RTLENTRY istream::operator>> (signed char _FAR & _c) {
  515.                 if( ipfx0() )
  516.                     _c = bp->in_avail() ? bp->sbumpc() : do_get();
  517.                 return *this;
  518.                 }
  519. inline istream _FAR & _RTLENTRY istream::operator>> (unsigned char _FAR & _c) {
  520.                 if( ipfx0() )
  521.                     _c = bp->in_avail() ? bp->sbumpc() : do_get();
  522.                 return *this;
  523.                 }
  524. #endif
  525. inline istream _FAR & _RTLENTRY istream::operator>> (signed char  _FAR * _p) {
  526.                 return  *this >> (char _FAR *)_p;
  527.                 }
  528. inline istream _FAR & _RTLENTRY istream::operator>> (unsigned char  _FAR * _p) {
  529.                 return  *this >> (char _FAR *)_p;
  530.                 }
  531. inline istream _FAR & _RTLENTRY istream::get(signed char  _FAR * _p, int _l, char _t) {
  532.                 return get((char _FAR *)_p, _l, _t);
  533.                 }
  534. inline istream _FAR & _RTLENTRY istream::get(unsigned char  _FAR * _p, int _l, char _t) {
  535.                 return get((char _FAR *)_p, _l, _t);
  536.                 }
  537. inline istream _FAR & _RTLENTRY istream::read(signed char  _FAR * _p, int _l) {
  538.                 return read((char _FAR *)_p, _l);
  539.                 }
  540. inline istream _FAR & _RTLENTRY istream::read(unsigned char  _FAR * _p, int _l) {
  541.                 return read((char _FAR *)_p, _l);
  542.                 }
  543. inline istream _FAR & _RTLENTRY istream::getline(signed char  _FAR * _p, int _l, char _t) {
  544.                 return getline((char _FAR *) _p, _l, _t);
  545.                 }
  546. inline istream _FAR & _RTLENTRY istream::getline(unsigned char  _FAR * _p, int _l, char _t) {
  547.                 return getline((char _FAR *) _p, _l, _t);
  548.                 }
  549. inline int      _RTLENTRY istream::sync() { return bp->sync(); }
  550. inline istream _FAR & _RTLENTRY istream::operator>> (istream _FAR & (_RTLENTRY *_f)(istream _FAR &)) {
  551.                 return (*_f)(*this);
  552.                 }
  553. #ifdef _BIG_INLINE_
  554. inline istream _FAR & _RTLENTRY istream::get(char _FAR & _c) {
  555.                 if( ipfx1() )
  556.                     if( bp->in_avail() ) {
  557.                         gcount_ = 1;
  558.                         _c = bp->sbumpc();
  559.                     }
  560.                 else _c = do_get();
  561.                 return *this;
  562.                 }
  563. inline istream _FAR & _RTLENTRY istream::get(signed char _FAR & _c) {
  564.                 if( ipfx1() )
  565.                     if( bp->in_avail()) {
  566.                         gcount_ = 1;
  567.                         _c = bp->sbumpc();
  568.                     }
  569.                 else _c = do_get();
  570.                 return *this;
  571.                 }
  572. inline istream _FAR & _RTLENTRY istream::get(unsigned char _FAR & _c) {
  573.                 if( ipfx1() )
  574.                     if( bp->in_avail() ) {
  575.                         gcount_ = 1;
  576.                         _c = bp->sbumpc();
  577.                     }
  578.                 else _c = do_get();
  579.                 return *this;
  580.                 }
  581. inline int _RTLENTRY istream::get() {
  582.                 if( ipfx1() ) {
  583.                     int _c = bp->sbumpc();
  584.                     if( _c == EOF ) setstate(eofbit);
  585.                     else gcount_ = 1;
  586.                     return _c;
  587.                 }
  588.                 else return EOF;
  589.                 }
  590. #endif
  591. inline int  _RTLENTRY istream::peek() { return ipfx1() ? bp->sgetc() : EOF; }
  592.  
  593.  
  594. class _EXPCLASS ostream : virtual public ios {
  595. public:
  596.     // constructors and destructor
  597.         _RTLENTRY ostream(streambuf _FAR *);
  598. virtual _RTLENTRY ~ostream();
  599.     // Obsolete constructors, for streams 1.2 compatibility
  600.         _RTLENTRY ostream(int _fd); // obsolete, use fstream
  601.         _RTLENTRY ostream(int _sz, char _FAR *); // obsolete, use strstream
  602.  
  603.     int _RTLENTRY opfx();      // output prefix function
  604.     void _RTLENTRY osfx();     // output suffix function
  605.     ostream _FAR & _RTLENTRY flush();
  606.  
  607.     // set/read the put pointer's position
  608.     ostream _FAR & _RTLENTRY seekp(streampos);
  609.     ostream _FAR & _RTLENTRY seekp(streamoff, ios::seek_dir);
  610.     streampos _RTLENTRY tellp();
  611.  
  612.     /*
  613.      * Unformatted insertion operations
  614.      */
  615.     ostream _FAR & _RTLENTRY put(         char);  // insert the character
  616.     ostream _FAR & _RTLENTRY put(signed   char);  // insert the character
  617.     ostream _FAR & _RTLENTRY put(unsigned char);  // insert the character
  618.     ostream _FAR & _RTLENTRY write(const          char _FAR *, int); // insert the string
  619.     ostream _FAR & _RTLENTRY write(const   signed char _FAR *, int); // insert the string
  620.     ostream _FAR & _RTLENTRY write(const unsigned char _FAR *, int); // insert the string
  621.  
  622.     /*
  623.      * Formatted insertion operations
  624.      */
  625.     // insert "true" or "false" for bool
  626.     ostream _FAR & _RTLENTRY ostream::operator<< (bool);
  627.  
  628.     // insert the character
  629.     ostream _FAR & _RTLENTRY operator<< (         char);
  630.     ostream _FAR & _RTLENTRY operator<< (  signed char);
  631.     ostream _FAR & _RTLENTRY operator<< (unsigned char);
  632.  
  633.     // for the following, insert character representation of numeric value
  634.     ostream _FAR & _RTLENTRY operator<< (short);
  635.     ostream _FAR & _RTLENTRY operator<< (unsigned short);
  636.     ostream _FAR & _RTLENTRY operator<< (int);
  637.     ostream _FAR & _RTLENTRY operator<< (unsigned int);
  638.     ostream _FAR & _RTLENTRY operator<< (long);
  639.     ostream _FAR & _RTLENTRY operator<< (unsigned long);
  640. #if defined(__FLAT__) && !defined(__STDC__) && (__BORLANDC__  >= 0x0520) && defined (_INTEGRAL_MAX_BITS) && (_INTEGRAL_MAX_BITS >= 64)
  641.     ostream _FAR & _RTLENTRY operator<< (__int64);
  642.     ostream _FAR & _RTLENTRY operator<< (unsigned __int64);
  643. #endif   
  644.     ostream _FAR & _RTLENTRY operator<< (float);
  645.     ostream _FAR & _RTLENTRY operator<< (double);
  646.     ostream _FAR & _RTLENTRY operator<< (long double);
  647.  
  648.     // insert the null-terminated string
  649.     ostream _FAR & _RTLENTRY operator<< (const          char _FAR *);
  650.     ostream _FAR & _RTLENTRY operator<< (const   signed char _FAR *);
  651.     ostream _FAR & _RTLENTRY operator<< (const unsigned char _FAR *);
  652.  
  653.     // insert character representation of the value of the pointer
  654.     ostream _FAR & _RTLENTRY operator<< (void _FAR *);
  655.  
  656.     // extract from streambuf, insert into this ostream
  657.     ostream _FAR & _RTLENTRY operator<< (streambuf _FAR *);
  658.  
  659.     // manipulators
  660.     ostream _FAR & _RTLENTRY operator<< (ostream _FAR & (_RTLENTRY *_f)(ostream _FAR &));
  661.     ostream _FAR & _RTLENTRY operator<< (ios _FAR & (_RTLENTRY *_f)(ios _FAR &));
  662.  
  663. protected:
  664.     int     _RTLENTRY do_opfx();   // implementation of opfx
  665.     void    _RTLENTRY do_osfx();   // implementation of osfx
  666.             _RTLENTRY ostream();
  667.  
  668. private:
  669.     void    _RTLENTRY outstr(const char _FAR *, const char _FAR *);
  670. };
  671. inline int  _RTLENTRY ostream::opfx() { return ospecial ? do_opfx() : 1; }
  672. inline void _RTLENTRY ostream::osfx() { if( x_flags & (stdio | unitbuf) ) do_osfx(); }
  673. #ifdef _BIG_INLINE_
  674. inline ostream _FAR & _RTLENTRY ostream::operator<< (char _c) {
  675.                 if( opfx() )
  676.                     if( bp->sputc(_c) == EOF ) setstate(badbit);
  677.                         osfx();
  678.                 return *this;
  679.                 }
  680. #endif
  681. inline ostream _FAR & _RTLENTRY ostream::operator<< (signed char _c) {
  682.                 return *this << (char)_c;
  683.                 }
  684. inline ostream _FAR & _RTLENTRY ostream::operator<< (unsigned char _c) {
  685.                 return *this << (char)_c;
  686.                 }
  687. inline ostream _FAR & _RTLENTRY ostream::operator<< (const char _FAR * _s) {
  688.                 outstr(_s, (const char _FAR *)0);
  689.                 return *this;
  690.                 }
  691. inline ostream _FAR & _RTLENTRY ostream::operator<< (const signed char _FAR * _s) {
  692.                 outstr((const char _FAR *)_s, (const char _FAR *)0);
  693.                 return *this;
  694.                 }
  695. inline ostream _FAR & _RTLENTRY ostream::operator<< (const unsigned char _FAR * _s) {
  696.                 outstr((const char _FAR *)_s, (const char _FAR *)0);
  697.                 return *this;
  698.                 }
  699. inline ostream _FAR & _RTLENTRY ostream::operator<< (short _i)
  700.                 { return *this << (long) _i; }
  701. inline ostream _FAR & _RTLENTRY ostream::operator<< (unsigned short _i)
  702.                 { return *this << (unsigned long) _i; }
  703. inline ostream _FAR & _RTLENTRY ostream::operator<< (int _i)
  704.                 { return *this << (long) _i; }
  705. inline ostream _FAR & _RTLENTRY ostream::operator<< (unsigned int _i)
  706.                 { return *this << (unsigned long) _i; }
  707. inline ostream _FAR & _RTLENTRY ostream::operator<< (float _f)
  708.                 { return *this << (double) _f; }
  709. inline ostream _FAR & _RTLENTRY ostream::operator<< (ostream _FAR & (_RTLENTRY *_f)(ostream _FAR &))
  710.                 { return (*_f)(*this); }
  711. inline ostream _FAR & _RTLENTRY ostream::write(const signed char _FAR * _s, int _n)
  712.                 { return write((const char _FAR *)_s, _n); }
  713. inline ostream _FAR & _RTLENTRY ostream::write(const unsigned char _FAR * _s, int _n)
  714.                 { return write((const char _FAR *)_s, _n); }
  715. inline ostream _FAR & _RTLENTRY ostream::put(char _c) {
  716.                 if( bp->sputc(_c) == EOF ) setstate(badbit);
  717.                 return *this;
  718.                 }
  719. inline ostream _FAR & _RTLENTRY ostream::put(signed char _c)
  720.                 { return put((char) _c); }
  721. inline ostream _FAR & _RTLENTRY ostream::put(unsigned char _c)
  722.                 { return put((char) _c); }
  723. #ifdef _BIG_INLINE_
  724. inline ostream _FAR & _RTLENTRY ostream::write(const char _FAR * _s, int _n) {
  725.                 if( ! fail() )
  726.                     if( bp->sputn(_s, _n) != _n )
  727.                         setstate(badbit);
  728.                 return *this;
  729.                 }
  730. #endif
  731.  
  732.  
  733. class _EXPCLASS iostream : public istream, public ostream {
  734. public:
  735.         _RTLENTRY iostream(streambuf _FAR *);
  736. virtual _RTLENTRY ~iostream();
  737.  
  738. protected:
  739.         _RTLENTRY iostream();
  740. };
  741.  
  742.  
  743. class _EXPCLASS istream_withassign : public istream {
  744. public:
  745.         // does no initialization
  746.         _RTLENTRY istream_withassign();
  747.  
  748. virtual _RTLENTRY ~istream_withassign();
  749.  
  750.     // gets buffer from istream and does entire initialization
  751.     istream_withassign _FAR & _RTLENTRY operator= (istream _FAR &);
  752.  
  753.     // associates streambuf with stream and does entire initialization
  754.     istream_withassign _FAR & _RTLENTRY operator= (streambuf _FAR *);
  755. };
  756.  
  757.  
  758. class _EXPCLASS ostream_withassign : public ostream {
  759. public:
  760.         // does no initialization
  761.         _RTLENTRY ostream_withassign();
  762.  
  763. virtual _RTLENTRY ~ostream_withassign();
  764.  
  765.     // gets buffer from istream and does entire initialization
  766.     ostream_withassign _FAR & _RTLENTRY operator= (ostream _FAR &);
  767.  
  768.     // associates streambuf with stream and does entire initialization
  769.     ostream_withassign _FAR & _RTLENTRY operator= (streambuf _FAR *);
  770. };
  771.  
  772.  
  773. class _EXPCLASS iostream_withassign : public iostream {
  774. public:
  775.         // does no initialization
  776.         _RTLENTRY iostream_withassign();
  777.  
  778. virtual _RTLENTRY ~iostream_withassign();
  779.  
  780.     // gets buffer from stream and does entire initialization
  781.     iostream_withassign _FAR & _RTLENTRY operator= (ios _FAR &);
  782.  
  783.     // associates streambuf with stream and does entire initialization
  784.     iostream_withassign _FAR & _RTLENTRY operator= (streambuf _FAR *);
  785. };
  786.  
  787. #if defined(__FLAT__)
  788.  
  789. /*
  790.  * The predefined streams
  791.  */
  792. extern istream_withassign _RTLENTRY _EXPDATA cin;
  793. extern ostream_withassign _RTLENTRY _EXPDATA cout;
  794. extern ostream_withassign _RTLENTRY _EXPDATA cerr;
  795. extern ostream_withassign _RTLENTRY _EXPDATA clog;
  796.  
  797. /*
  798.  * Manipulators
  799.  */
  800.  
  801. ostream _FAR &  _RTLENTRY _EXPFUNC endl(ostream _FAR &); // insert newline and flush
  802. ostream _FAR &  _RTLENTRY _EXPFUNC ends(ostream _FAR &); // insert null to terminate string
  803. ostream _FAR &  _RTLENTRY _EXPFUNC flush(ostream _FAR &);// flush the ostream
  804. ios _FAR &      _RTLENTRY _EXPFUNC dec(ios _FAR &);      // set conversion base to decimal
  805. ios _FAR &      _RTLENTRY _EXPFUNC hex(ios _FAR &);      // set conversion base to hexadecimal
  806. ios _FAR &      _RTLENTRY _EXPFUNC oct(ios _FAR &);      // set conversion base to octal
  807. istream _FAR &  _RTLENTRY _EXPFUNC ws(istream _FAR &);   // extract whitespace characters
  808.  
  809. ios&            _RTLENTRY _EXPFUNC lock(ios&);     // lock file handle
  810. ios&            _RTLENTRY _EXPFUNC unlock(ios&);   // unlock file handle
  811.  
  812. #else /* __FLAT__  */
  813.  
  814. /*
  815.  * The predefined streams
  816.  */
  817. extern istream_withassign _RTLENTRY  cin;
  818. extern ostream_withassign _RTLENTRY  cout;
  819. extern ostream_withassign _RTLENTRY  cerr;
  820. extern ostream_withassign _RTLENTRY  clog;
  821.  
  822. /*
  823.  * Manipulators
  824.  */
  825.  
  826. ostream _FAR &  _RTLENTRY  endl(ostream _FAR &); // insert newline and flush
  827. ostream _FAR &  _RTLENTRY  ends(ostream _FAR &); // insert null to terminate string
  828. ostream _FAR &  _RTLENTRY  flush(ostream _FAR &);// flush the ostream
  829. ios _FAR &      _RTLENTRY  dec(ios _FAR &);      // set conversion base to decimal
  830. ios _FAR &      _RTLENTRY  hex(ios _FAR &);      // set conversion base to hexadecimal
  831. ios _FAR &      _RTLENTRY  oct(ios _FAR &);      // set conversion base to octal
  832. istream _FAR &  _RTLENTRY  ws(istream _FAR &);   // extract whitespace characters
  833.  
  834. ios&            _RTLENTRY  lock(ios&);     // lock file handle
  835. ios&            _RTLENTRY  unlock(ios&);   // unlock file handle
  836.  
  837. #endif
  838.  
  839. #if !defined(__FLAT__)
  840. /*
  841.  * Initialization call for Easy Windows
  842.  */
  843. extern "C" void  _RTLENTRY _InitEasyWin(void);
  844. #endif
  845.  
  846.  
  847. #if !defined(RC_INVOKED)
  848.  
  849. #pragma option -Vo.     // restore user C++ options
  850.  
  851. #if !defined(__TINY__)
  852. #pragma option -RT.
  853. #endif
  854.  
  855. #if defined(__BCOPT__)
  856. #if !defined(_RTL_ALLOW_po) && !defined(__FLAT__)
  857. #pragma option -po.     // restore Object data calling convention
  858. #endif
  859. #endif
  860.  
  861. /* restore default packing */
  862. #pragma pack(pop)
  863.  
  864. #if defined(__STDC__)
  865. #pragma warn .nak
  866. #endif
  867.  
  868. #endif  /* !RC_INVOKED */
  869.  
  870.  
  871. #endif  /* __IOSTREAM_H */
  872.